<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../../lib/vue.js"></script>
    <style>
        .active{
            background-attachment: red;
        }
    </style>
</head>
<body>
    <div id="box">
        <ul>
            <li v-for="(item, index) in dataList" :class=" current===index?'active':'' " @click="handleClick(index)">
                {{item}}
            </li>
        </ul>
    </div>

    <script>
        new Vue({
            el:"#box",
            data: {
                dataList: [
                    "首页","列表","购物车"
                ],
                current: 0
            },
            methods: {
                handleClick(index) {
                    this.current = index
                    console.log(index)
                }
            }
        })
    </script>
</body>

</html>